package com.wbw.ssb.controller;

import com.wbw.ssb.common.api.CommonResult;
import com.wbw.ssb.mbg.entity.System;
import com.wbw.ssb.service.SystemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: guibo
 * @Description:
 * @Date: Created in 3:49 2021/5/19
 * @Modified By:
 */
@RestController
@Api(tags = "系统管理")
@RequestMapping("/system")
public class SystemController {

    @Autowired
    SystemService systemService;

    @GetMapping(value = "/info")
    @ApiOperation("获取系统配置")
    @PreAuthorize("hasAnyAuthority('管理员','员工')")
    CommonResult<System> info(){
        return CommonResult.success(systemService.getInfo());
    }

    @PutMapping(value = "/update")
    @ApiOperation("更改系统配置")
    @PreAuthorize("hasAnyAuthority('管理员')")
    CommonResult<Integer> update(@RequestBody System system){
        return CommonResult.success(systemService.update(system));
    }

}
